# 创建集合
"""
# 自动去除重复
s = {23, 9, 78, 6, 45, 9, 23, 23, 78, 100}
# print(s)
# 可以遍历集合
# for i in s:
#     print(i)
print(23 in s)
print(len(s))

names = {'小明', '小东', '小美', '小红'}
# 添加元素
# names.add('小军')
# names.add('小雅')
# 删除元素
names.remove('小东')
print(names)
"""

num1 = {1, 2, 3, 4}
num2 = {3, 4, 5, 6}
# 交集
# print(num1.intersection(num2), num1 & num2)
# 并集
# print(num1.union(num2), num1 | num2)
# 差集
# print(num1.difference(num2), num2.difference(num1))
# print(num1 - num2, num2 - num1)


# 列表去重
lst = [1, 2, 2, 3, 1, 4, 3, 5, 5, 4]
# 转为集合即可去重
s = set(lst)
# 转回成列表
l = list(s)
print(l)


